home *** CD-ROM | disk | FTP | other *** search
/ Champak 29 / Volume 29 - JOGO DISK .iso / Games / jungle_adventure.swf / scripts / __Packages / PerformanceTest.as < prev    next >
Text File  |  2006-11-29  |  2KB  |  71 lines

  1. class PerformanceTest
  2. {
  3.    var score = 0;
  4.    var time = 0;
  5.    var loops = 20;
  6.    var complete = false;
  7.    function PerformanceTest(itterations, onComplete)
  8.    {
  9.       if(itterations)
  10.       {
  11.          this.loops = itterations;
  12.       }
  13.       this.remainingLoops = this.loops;
  14.       if(onComplete)
  15.       {
  16.          this.onComplete = onComplete;
  17.       }
  18.       var _loc2_ = System.capabilities.version.substr(4).split(",");
  19.       this.flashMajorVersion = Number(_loc2_[0]);
  20.       this.flashMinorVersion = Number(_loc2_[2]);
  21.       this.complete = false;
  22.       this.intervalID = setInterval(function(o)
  23.       {
  24.          o.test();
  25.       }
  26.       ,0,this);
  27.    }
  28.    function test()
  29.    {
  30.       if(this.remainingLoops <= 0)
  31.       {
  32.          this.finalize();
  33.          clearInterval(this.intervalID);
  34.          return undefined;
  35.       }
  36.       this.remainingLoops = this.remainingLoops - 1;
  37.       var _loc4_ = getTimer();
  38.       var _loc3_ = undefined;
  39.       var _loc2_ = 0;
  40.       while(_loc2_ < 6400)
  41.       {
  42.          _loc3_ = {};
  43.          _loc2_ = _loc2_ + 1;
  44.       }
  45.       this.time += getTimer() - _loc4_;
  46.    }
  47.    function finalize()
  48.    {
  49.       this.score = Math.floor(this.loops / this.time * 10000);
  50.       if(this.flashMajorVersion >= 7)
  51.       {
  52.          this.log = Math.log(this.score * 0.015);
  53.       }
  54.       else
  55.       {
  56.          this.log = Math.log(this.score * 0.023);
  57.       }
  58.       this.processor = this.log * 1000;
  59.       this.complete = true;
  60.       this.onComplete(this);
  61.    }
  62.    function toString()
  63.    {
  64.       if(this.score)
  65.       {
  66.          return "Loops:\t" + this.loops + "\nFlash Version: \t" + System.capabilities.version + "\nTotal Time:\t" + this.time + "\nScore: \t" + this.score + "\nProcessor: \t" + this.processor;
  67.       }
  68.       return "Test In Process.";
  69.    }
  70. }
  71.